import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String s1 = scan.nextLine();
        String s2 = scan.nextLine();
        int len1 = s1.length();
        int len2 = s2.length();
        int maxLen = 0;
        int[] dp = new int[len2+1];
        for (int i = 1; i <= len1; i++) {
            for (int j = dp.length-1; j > 0; j--) {
                if (s1.charAt(i - 1) == s2.charAt(j - 1)) {
                    dp[j] =  dp[j - 1] + 1;
                    if (dp[j] > maxLen) {
                        maxLen = dp[j];
                    }
                }else{
                    dp[j] = 0;
                }
            }
        }
        System.out.println(maxLen);
    }
    public static void main1(String[] args) {
        Scanner scan = new Scanner(System.in);
        String s1 = scan.nextLine();
        String s2 = scan.nextLine();
        int n = s1.length();
        int m = s2.length();
        int maxLen = 0;
        int[] dp = new int[m + 1];
        for (int i = 1; i <= n; i++) {
            int prev = 0;
            for (int j = 1; j <= m; j++) {
                int temp = dp[j];
                if (s1.charAt(i - 1) == s2.charAt(j - 1)) {
                    dp[j] = prev + 1;
                    if (dp[j] > maxLen) {
                        maxLen = dp[j];
                    }
                } else {
                    dp[j] = 0;
                }
                prev = temp;
            }
        }
        System.out.println(maxLen);
    }
}

